package com.digitalchina.lxnsy.adapter;

import android.content.Context;
import android.view.ViewGroup;

import com.digitalchina.lxnsy.constant.Constant;
import com.digitalchina.lxnsy.interfaces.IRecyclerType;
import com.digitalchina.lxnsy.viewholder.ActivityListHolder;
import com.digitalchina.lxnsy.viewholder.ConsultDynamicListHolder;
import com.digitalchina.lxnsy.viewholder.ConsultDynamicTypeHolder;
import com.digitalchina.lxnsy.viewholder.FarmingInfoHolder;
import com.digitalchina.lxnsy.viewholder.HomeShareTypeHolder;
import com.digitalchina.lxnsy.viewholder.HotActivityTypeHolder;
import com.digitalchina.lxnsy.viewholder.NewShareFarmListHolder;
import com.digitalchina.lxnsy.viewholder.ServiceTypeHolder;
import com.digitalchina.lxnsy.viewholder.ShareFarmListHolder;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：首页适配器
 * 包名：com.digitalchina.bigdata.activity
 * 创建人：郑皓
 * 创建时间：2017/3/24 15:30:17
 * 修改备注：
 * ================================================
 */

public class HomePageRecyclerAdapter extends RecyclerArrayAdapter<IRecyclerType> {


    public HomePageRecyclerAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {


        if (viewType == Constant.ITEM_TYPE_SHARE_TYPE) {//共享精选
            return new HomeShareTypeHolder(parent);
        } else
            if (viewType == Constant.ITEM_TYPE_SHARE_LIST) {
            return new NewShareFarmListHolder(parent);
        } else if (viewType == Constant.ITEM_TYPE_CONSULT_TYPE) {//咨询类型
            return new ConsultDynamicTypeHolder(parent);
        } else if (viewType == Constant.ITEM_TYPE_CONSULT_LIST) {
            return new ConsultDynamicListHolder(parent);
        } else if (viewType == Constant.ITEM_TYPE_ACTIVITY_TYPE) {//热门活动
            return new HotActivityTypeHolder(parent);
        } else if (viewType == Constant.ITEM_TYPE_ACTIVITY_LIST) {
            return new ActivityListHolder(parent);
        }

        return null;
    }

    @Override
    public int getViewType(int position) {

        if (position == 0) {
            return Constant.ITEM_TYPE_SHARE_TYPE;
//            return Constant.ITEM_TYPE_TECHNOLOGIES_TYPE;
        } else {
            return getItem(position).type();
        }
    }

}
